package com.zx.sdk.model;

import com.zx.sdk.ZxSDK;

/**
 * 已准备好的 广告素材
 */
public class ReadyAdPosition implements Comparable<ReadyAdPosition> {
    private String pid;
    private String league;
    private int cpm;
    private String billType;
    private String mapPid;
    private AdInfo mAdInfo;

    /**
     * 创建 实例，
     *
     * @param cpm 单位为 分
     */
    public static ReadyAdPosition of(AdInfo adInfo, int cpm) {
        ReadyAdPosition readyAdRes = new ReadyAdPosition();
        readyAdRes.setCpm(cpm)
            .setMapPid(adInfo.getMapPid())
            .setPid(adInfo.getPID())
            .setBillType(adInfo.getBillType())
            .setLeague(adInfo.getLeague())
            .setAdInfo(adInfo);
        return readyAdRes;
    }

    /**
     * 当前 adInfo 是否是 bidding位置
     */
    public boolean isBiddingType() {
        return ZxSDK.Bidding.equalsIgnoreCase(billType);
    }

    public String getPid() {
        return pid;
    }

    public ReadyAdPosition setPid(String pid) {
        this.pid = pid;
        return this;
    }

    public String getLeague() {
        return league;
    }

    public ReadyAdPosition setLeague(String league) {
        this.league = league;
        return this;
    }

    public int getCpm() {
        return cpm;
    }

    public ReadyAdPosition setCpm(int cpm) {
        this.cpm = cpm;
        return this;
    }

    public String getMapPid() {
        return mapPid;
    }

    public ReadyAdPosition setMapPid(String mapPid) {
        this.mapPid = mapPid;
        return this;
    }

    public String getBillType() {
        return billType;
    }

    public ReadyAdPosition setBillType(String billType) {
        this.billType = billType;
        return this;
    }

    public AdInfo getAdInfo() {
        return mAdInfo;
    }

    public void setAdInfo(AdInfo adInfo) {
        mAdInfo = adInfo;
    }

    /**
     * 价格倒序，从高架到低价
     */
    @Override
    public int compareTo(ReadyAdPosition o) {
        return this.cpm < o.cpm ? 1 : -1;
    }
}
